﻿using System.Linq;
using System.Web.Mvc;
using Start.Models;

namespace Start.Controllers
{
    [HandleError]
    public class PersonController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Persons List";

            PersonsDataContext dataContext = new PersonsDataContext();
            ViewData["Persons"] = dataContext.Persons.ToList();

            return View();
        }

        public ActionResult IndividualPerson(int id)
        {
            PersonsDataContext dataContext = new PersonsDataContext();

            Person person = dataContext.Persons.Where
                (p => p.ID == id).Single();
            ViewData["PersonName"] = person.Name;
            ViewData["Person"] = person;

            return View();
        }
    }
}
